home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20031118-20041115
/
000399_slash_dev_slas…_2000@yahoo.com_Wed Sep 22 09:14:02 2004.msg
< prev
next >
Wrap
Internet Message Format
|
2020-01-01
|
5KB
Path: newsmaster.cc.columbia.edu!panix!newsfeed.media.kyoto-u.ac.jp!postnews1.google.com!k26g2000oda.googlegroups.com!not-for-mail
From: "Mark Sapiro" <slash_dev_slash_null_2000@yahoo.com>
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Return codes and If statments
Date: 21 Sep 2004 21:30:19 -0700
Organization: http://groups.google.com
Lines: 166
Message-ID: <1095827419.338981.28270@k26g2000oda.googlegroups.com>
References: <3f9c05b0.0409211252.5aa51cb1@posting.google.com>
<slrncl18i5.56s.fdc@sesame.cc.columbia.edu>
NNTP-Posting-Host: 209.182.169.133
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1095827419 19272 127.0.0.1 (22 Sep 2004 04:30:19 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 22 Sep 2004 04:30:19 +0000 (UTC)
In-Reply-To: <slrncl18i5.56s.fdc@sesame.cc.columbia.edu>
User-Agent: G2/0.2
Complaints-To: groups-abuse@google.com
Injection-Info: k26g2000oda.googlegroups.com; posting-host=209.182.169.133;
posting-account=iQNWIg0AAAAD2fStXNC9nwGlPdSqjWrI
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:15177
Frank da Cruz wrote:
> On 2004-09-21, Peter V. <dm_v_2000@yahoo.com> wrote:
> : I am modifying a C-Kermit script I have to not continue processing
> : if a call to another script does not return a value of 1 (We are
doing
> : this for fail over testing).
> :
> : Here is the C-Kermit code in question:
> :
> : # run the db_status script in the CRON directory
> : run db_status
> :
> : # See if the ret value is != 1
> : # If it != 1 tell user we are not on the primay server and then
> : exit).
> :
> : if != \v(pexitstat) 1
> : {
> : echo Return code != 1 ... Not the primary server
> : echo return code = \v(pexitstat)
> : exit
> :
> : }
> : # otherwise we are on the primary server so continue processing
> : ...
> : ...
> : ...
> :
> : When I run this on the Secondary server it works (since the result
> : returned from the db_status script is a 2 since it is not the
primary
> : server).
> :
> : However, when I test this on the primay server the code exits
(meaning
> : it executes the body of the if statment above) despite the fact
that
> : the return code from db_status is 1.
> :
> : Any suggestions, as to what I'm doing wrong?
> :
> My first suggestion is to use the recommended format for grouping
statements:
>
> if != \v(pexitstat) 1 {
> echo Return code != 1 ... Not the primary server
> echo return code = \v(pexitstat)
> exit
> }
>
> If that doesn't help, then check to see what the subprocess actually
> returns as its exit code (OK, you say it is 1 but...). If so, then
make sure
> you are running the current version of C-Kermit, which is 8.0.211.
If you
> are, then we're in for some debugging; contact
kermit-support@columbia.edu.
>
> - Frank
Frank's suggestion will help. This is another case of if { } else { }
constructs that only work if written in certain ways.
I've mentioned this before, but the document
http://www.columbia.edu/kermit/ckermit70.html
contains several examples of if/else coding in section 7.20.1. The
first four of these are
Example 1:
IF condition { command1, command2 } ELSE { command3, command4 }
Example 2 (same as Example 1):
IF condition {
command1
command2
} ELSE {
command3
command4
}
Example 3 (same as 1 and 2):
IF condition {
command1
command2
}
ELSE { command3, command4 }
Example 4 (same as 1-3):
IF condition {
command1
command2
}
ELSE {
command3
command4
}
In examples 3 and 4, various problems occur in execution of the ELSE
clause when the condition is false. This change happened somewhere
between 8.0.201 and 8.0.206 due to changes in the handling of
"immediate macros". This is illustrated by the following.
fog: {14} $ cat kt3
# Example 1:
IF false { .theday := \v(day), show macro theday } ELSE { .thedate :=
\v(date), show macro thedate }
# Example 2 (same as Example 1):
IF false {
.theday := \v(day)
show macro theday
} ELSE {
.thedate := \v(date)
show macro thedate
}
# Example 3 (same as 1 and 2):
IF false {
.theday := \v(day)
show macro theday
}
ELSE { .thedate := \v(date), show macro thedate }
# Example 4 (same as 1-3):
IF false {
.theday := \v(day)
show macro theday
}
ELSE {
.thedate := \v(date)
show macro thedate
}
fog: {15} $ kermit
Executing /home_mo/msapiro/.kermrc for UNIX...
Executing /home_mo/msapiro/.mykermrc...
Good Evening.
C-Kermit 8.0.212 Dev.00, 10 May 2004, for HP-UX 11.00
Copyright (C) 1985, 2004,
Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/home_mo/msapiro/) C-Kermit>take kt3
thedate = 21 Sep 2004
thedate = 21 Sep 2004
thedate = \v(date)
thedate = \v(date)
(/home_mo/msapiro/) C-Kermit>
I have trained myself to always code if/else in the "recommended
format", but it would be nice if the examples that no longer work were
removed from the documentation.
--
Mark Sapiro msapiro at value dot net The highway is for gamblers,
San Francisco Bay Area, California better use your sense - B. Dylan